package com.fgw.admin.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.fgw.admin.dto.ResultInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.fgw.admin.entity.PersonalInformation;
import com.fgw.admin.service.IPersonalInformationService;

/**
 * 人员信息 前端控制器
 *
 * @author system
 * @date 2020-11-16 22:38:52
 */
@Controller
@RequestMapping("/personalInformation")
public class PersonalInformationController {
    @Resource
    private IPersonalInformationService iPersonalInformationService;

    @RequestMapping("/*")
    public void toHtml(){

    }

    @RequestMapping("/list")
    @RequiresPermissions("personalInformation:view")
    public @ResponseBody
    ResultInfo<List<PersonalInformation>> listData(PersonalInformation personalInformation, Integer page, Integer limit){
        EntityWrapper<PersonalInformation> wrapper = new EntityWrapper<>(personalInformation);
        Page<PersonalInformation> pageObj = iPersonalInformationService.selectPage(new Page<>(page,limit), wrapper);
        return new ResultInfo<>(pageObj.getRecords(), pageObj.getTotal());
    }

    @RequestMapping("/add")
    @RequiresPermissions("personalInformation:add")
    public @ResponseBody
    ResultInfo<Boolean> add(PersonalInformation personalInformation){
        boolean b = iPersonalInformationService.insert(personalInformation);
        return new ResultInfo<>(b);
    }

    @RequestMapping("/delBatch")
    @RequiresPermissions("personalInformation:del")
    public @ResponseBody
    ResultInfo<Boolean> delBatch(Integer[] idArr){
        boolean b = iPersonalInformationService.deleteBatchIds(Arrays.asList(idArr));
        return new ResultInfo<>(b);
    }

    @RequestMapping("/edit")
    @RequiresPermissions("personalInformation:edit")
    public @ResponseBody
    ResultInfo<Boolean> edit(PersonalInformation personalInformation){
        boolean b = iPersonalInformationService.updateById(personalInformation);
        return new ResultInfo<>(b);
    }

}
